{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
$(window).load(
  function() {
    loadAvPhotos();
  });

  function selectPhoto(fileId) {
    if ($('#photo' + fileId).hasClass('available')){
      $.post('/admin/galleries/photo/select/' + fileId + '/{{ galleryId }}/');
      $('#photo' + fileId).css('border', '1px solid red');
      $('#photo' + fileId).removeClass('available');
      $('#photo' + fileId).addClass('notavailable');
    } else {
      $.post('/admin/galleries/photo/unselect/' + fileId + '/{{ galleryId }}/');
      $('#photo' + fileId).css('border', '0');
      $('#photo' + fileId).removeClass('notavailable');
      $('#photo' + fileId).addClass('available');
    }
  }

  function publish(gid) {
    $.post('/admin/galleries/publish/' + gid + '/');
  }
  function unpublish(gid) {
    $.post('/admin/galleries/unpublish/' + gid + '/');
  }
</script>
{% endblock %}
{% block content %}
        <h1>Galleries</h1>
        <h2><a href="/admin/galleries//new/" class="add">Añadir gallery</a></h2>
        <p><a href="/admin/gallerytags">Tags</a></p>
        <select name="categories" id="categories" style="float:right; margin-top: -50px; display: block">
          {% for cat in categories %}
            <tr>
              <option value="{{ cat.slug }}">{{ cat.name }}</option>
            </tr>
          {% endfor %}
        </select>
        <table class="imgswithoutborders">
        {% for gallery in galleries %}
          <tr>
            <td><strong>{{ gallery.title }}</strong></td>
            <td>{% if gallery.draft %}<input type="button" value="publish" onclick="publish({{ gallery.galleryId }})" />{% endif %}</td>
            <td><a href="/galleries/{{ gallery.galleryId }}">Public</a></td>
            <td><a href="/admin/galleries/{{ gallery.key }}/edit/?c=man">Editar</a></td>
            <td><a href="/admin/galleries/{{ gallery.key }}/delete/" onclick="if(confirm('¿Do you really want to delete {{ gallery.title }}?')){return true;}else{return false;}">Borrar</a></td>
          </tr>
        {% endfor %}
        </table>

{% endblock %}
